import { resolve } from 'path';
import { defineConfig } from 'vitepress';
import AutoImport from 'unplugin-auto-import/vite';
import UnoCSS from 'unocss/vite';
import { nav, sidebar } from './utils/sidebar';
import { MarkdownTransform } from '../plugins/index.js';
import {
  containerDirectiveMount,
  tag
} from '../packages/plugin/containerPreview';
import vueJsx from '@vitejs/plugin-vue-jsx';

// https://vitepress.dev/reference/site-config
export default defineConfig({
  title: 'PC组件库',
  description: 'PC组件库',
  ignoreDeadLinks: true,
  themeConfig: {
    // https://vitepress.dev/reference/default-theme-config
    nav,
    logoLink: '/zh-CN/button.html',
    sidebar
    // socialLinks: [
    //   // { icon: 'github', link: 'http://localhost:5173/zh-CN/button.html' },
    // ],
  },
  markdown: {
    config(md) {
      md.use(tag);
      md.use(containerDirectiveMount);
    }
  },
  vite: {
    plugins: [
      UnoCSS(),
      vueJsx(),
      MarkdownTransform(),
      AutoImport({
        imports: ['vue', 'vue-router'],
        vueTemplate: true,
        eslintrc: {
          enabled: true,
          filepath: '../../.eslintrc-auto-import.json',
          globalsPropValue: true
        },
        dts: false
      })
    ],
    resolve: {
      alias: {
        '@': resolve(__dirname, '../../src')
      },
      extensions: ['.js', '.json', '.ts']
    }
  }
});
